using MengCC.Core.Data;
using MengCC.Core.IO;
using MengCC.Core.Plugins;
using MengCC.Core.Projects;
using MengCC.Core.Works;
using MengCC.Framework.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace MengCC.Test
{
    [TestClass]
    public class WorkTest
    {
        [TestMethod]
        public void StartWork()
        {
            IBaseRepository<BuildLog, string> buildLogRepository = new BaseRepository<BuildLog, string>();
            IBaseRepository<Project, int> projectRepository = new BaseRepository<Project, int>();
            ProjectManager projectManager = new ProjectManager(buildLogRepository, projectRepository);

            var currentDir = Environment.CurrentDirectory;
            PluginManager pluginManager = new PluginManager(Path.Combine(currentDir, "../../../../", @"MengCC.Plugin.Demo\bin"));
            pluginManager.LoadPlugins();

            var project =projectManager.AddProject(new Project
            {
                Name = "testproject",
                BuildPlugins = new List<PluginInfo>
                  {
                      new PluginInfo
                      {
                           Id="demo",
                           Config="BuildPlugins config data",
                      }
                  },
                 IsClearBeforeBuilding = false,
                  RepositoryPlugins = new List<PluginInfo>
                  {
                      new PluginInfo
                      {
                           Id="demo",
                           Config="RepositoryPlugins config data",
                      }
                  },

            });


            WorkManager workManager = new WorkManager(pluginManager, projectManager, new IOManager(),"");
            workManager.StartWork(project.Id);
        }
    }
}
